﻿using System;

namespace ArrayApplication
{
    class MyArray
    {
        double GetAverage(int[] arr, int size)
        {
            int i;
            double avg;
            int sum = 0;

            for (i = 0; i < size; ++i)
            {
                sum += arr[i];
            }

            avg = (double)sum / size;
            return avg;
        }
        static void Main(string[] arg)
        {
            MyArray app = new MyArray();
            /* 一个带有 5 个元素的 int 数组 */
            int[] balance = new int[] { 1000, 2, 3, 17, 50 };
            double avg;

            /* 传递数组的指针作为参数 */
            avg = app.GetAverage(balance, 5);

            /* 输出返回值 */
            Console.WriteLine("平均值是：{0}", avg);
            Console.ReadKey();
        }
    }
}